import axios from 'axios';
export default {
    data(){
        return {
            list:[],
            total:0,
        }
    },
    methods: {
        async getList(params={}){
            console.log(params,'请求参数');
            let res = await axios.get(this.url,this.params);
            console.log(res.data,'数据返回');
            this.list= res.data.data
            this.total = res.data.data?.length || 0;
        },
        delList(){
            this.$confirm('您确定要删除数据吗？','删除提示').then(async ()=>{
                let res = await axios.delete(this.url)
                this.$message.success(res.data.msg);
            }).catch(err=>{
                this.$message.info(err)
            })
        },
        async addList(params){
            try {
                let res = await axios.post(this.url,params);

                this.$message.success(res.data.msg);
            } catch (error) {
                this.$message.error(error);
            }
        },
        async update(params){
            try {
                let res = await axios.put(this.url,params);

                this.$message.success(res.data.msg);
            } catch (error) {
                this.$message.error(error);
            }
        }
    },
    created() {
        this.getList();
    },
}